/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 09 - 10
 * Time: 12:12
 */
//牛客 最小花费爬楼梯
public class Solution1 {
    public int minCostClimbingStairs (int[] cost) {//楼顶是cost数组最后一个元素的后一个元素
        int n = cost.length;
        int[] dp = new int[n + 1];//dp[i]表示到达i位置时的最小花费
        for (int i = 2; i <= n ; i++) {
            dp[i] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
        }
        return dp[n];
    }
}
